package com.woniuxy.controller;


import com.woniuxy.controller.info.MenuInfo;
import com.woniuxy.controller.info.UserInfo;
import com.woniuxy.service.MenuModelService;
import com.woniuxy.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 马世亮
 * @since 2022-02-15
 */
@Api(tags = "菜单接口")
@RestController
@RequestMapping("/menuModel")
public class MenuModelController {

    @Resource
    private MenuModelService menuModelService;

    @ApiOperation("获取对于角色的菜单信息")
    @PostMapping("/getmenu")
    public Result getMenu(){
        UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        System.out.println(userInfo.getId());
        List<MenuInfo> menus = menuModelService.findMenusByAccountId(userInfo.getId());

        return Result.success(200,"获取成功",menus);
    }

}

